package com.kasax.ipcbus.hermes;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.kasax.ipcbus.corel.CorelService;
import com.kasax.ipcbus.corel.Hermes;
import com.kasax.ipcbus.utils.GsonUtils;
import com.kasax.ipcbus.utils.LogUtils;

public class ClientActivity extends AppCompatActivity {

    private IUserManager iUserManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_client);

        setTitle("客户端界面");

        Hermes.getDefault().connect(this, CorelService.class);
    }

    public void handleGetInstans(View view) {
        iUserManager = Hermes.getDefault().getInstance(IUserManager.class);
        LogUtils.i(getClass(), "iUserManager: " + iUserManager);
    }

    public void handleCallInstans(View view) {
        if (iUserManager != null) {
            Student student = iUserManager.getStudent();
            Toast.makeText(this, "result: " + GsonUtils.toJson(student), Toast.LENGTH_LONG).show();
        }
    }
}